local skel = fk.CreateSkill {
  name = "lb__chouzhuo",
}

Fk:loadTranslationTable {
  ["lb__chouzhuo"] = "仇灼",
  [":lb__chouzhuo"] = "当你受到其他角色造成的伤害后，你可以横置一名其他角色并发动<a href=':lb__zhuhuo'><font color='red'>〖逐火〗</font></a>，然后将牌堆顶的十二张牌扣置于武将牌上，称为「<b>仇灼</b>」，最后你对自己造成1点火焰伤害。",

  ["#lb__chouzhuo"] = "仇灼：你可以横置一名其他角色后发动〖逐火〗",

  ["$lb__chouzhuo"] = "仇灼",
  ["@@lb__chouzhuo"] = "仇灼",
  ["@[player]lb__chouzhuo"] = "仇灼",

  ["$lb__chouzhuo1"] = "此身的火焰，还不够猛烈。",
  ["$lb__chouzhuo2"] = "以血淬火！",
  ["$lb__chouzhuo3"] = "亿万火种之怒，燃尽此身！",
}

skel:addEffect(fk.Damaged, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and data.from ~= player
        and table.find(player.room:getOtherPlayers(player), function(to)
          return not to.chained
        end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = table.filter(room:getOtherPlayers(player), function(to)
      return not to.chained
    end)
    if #tos > 0 then
      tos = room:askToChoosePlayers(player, {
        targets = tos,
        min_num = 1,
        max_num = 1,
        skill_name = skel.name,
        cancelable = true,
        prompt = "#lb__chouzhuo",
      })
      if #tos > 0 then
        event:setCostData(self, { tos = tos })
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    to:setChainState(true)
    room:setPlayerMark(to, "@@lb__chouzhuo", 1)
    room:addTableMarkIfNeed(player, "@[player]lb__chouzhuo", to.id)
    if player:isAlive() and not player.chained then
      local zhuhuo = Fk.skills["lb__zhuhuo"] ---@type TriggerSkill
      if zhuhuo then
        room:notifySkillInvoked(player, "lb__zhuhuo")
        player:broadcastSkillInvoke("lb__zhuhuo")
        zhuhuo:use(event, nil, player)
      end
    end
    if player:isAlive() then
      player:addToPile("$lb__chouzhuo", room:getNCards(12), false, skel.name, player, {})
    end
    if player:isAlive() then
      room:damage {
        from = player,
        to = player,
        skillName = skel.name,
        damage = 1,
        damageType = fk.FireDamage
      }
    end
  end,
})

skel:addEffect("visibility", {
  card_visible = function(self, player, card)
    if player:getPileNameOfId(card.id) == "$lb__chouzhuo" then
      return false
    end
  end,
})

return skel